program demo;

uses
  SysUtils, uTyp, uVar, uEng, uSpr, uInp, uFnt, uDrw, uSnd;

type
  TEng = class(uEng.TEng)
    procedure OnInit; override;
    procedure OnFrame; override;
    procedure OnStep; override;
  end;

procedure TEng.OnInit;
begin
  //spr.Add('spr', res.AddTex('tex', 'data/dance.tga', True), 'canvas');
  spr.AddDyn('dance', res.AddTex('tex', 'data/dance.tga', True)).Add('dance', 'canvas', 6, 2, 5, SPR_LOOP);
  res.AddFnt('fnt', 'fnt', 28, 500, 'Tahoma', 512, 512, True);
  snd.Add('s', 'data/s.ogg', True, False, -1);
end;

procedure TEng.OnFrame;
begin
  spr.Draw;
  //res.FindFnt('fnt').Draw('Hello, World!', 200, 200, MakeClr($FFFFFF00));
  //res.FindFnt('fnt').Draw('Snd bufs: ' + IntToStr(snd.Find('s').factSize), 10, 10, MakeClr($FFFFFFFF));
  //drw.Circle(200, 200, 100, 100, MakeClr($99FFFFFF), DRW_FILL);
end;

procedure TEng.OnStep;
begin
  if inp.KeyDowned(KEY_ESCAPE) then eng.Stop;
  if inp.KeyPressed(KEY_P) then spr.FindDyn('dance').Play('dance');//snd.Find('s').FindBuf.Play;
end;

begin
  eng := TEng.Create;
  //eng.conf.renderer := ENG_D3D8;
  //eng.conf.player := ENG_DS;

  if eng.Init then
    eng.Start;

  eng.Free;
end.
